import React from 'react'
import {IGood, IGoodsType} from '@/model/declare'
import {View} from '@tarojs/components'
import {ScrollGoodsList} from './Scroll'
import {OneGoodsList} from './One'
import {TwoGoodsList} from './Two'
import {ActivityGoodsList} from "./Activity";

import './index.scss'

export interface GoodsListProps {
    type: IGoodsType
    title: string
    items: IGood[]
}

/**
 * 商品列表
 * @param param0
 */
export const GoodsList: React.FC<GoodsListProps> = ({
    type,
    items,
    title
}) => {
    const renderChild = ()=>{

        const ps = {type, items, title }
        switch (type) {
            case IGoodsType.SCROLL:
                return <ScrollGoodsList {...ps} />
            case IGoodsType.ONE:
                return <OneGoodsList {...ps} />
          case IGoodsType.ACTIVITY:
                return <ActivityGoodsList {...ps} />
            default:
                return <TwoGoodsList {...ps} />
        }
    }

    return (
        <View className='xxm-goods-list'>
            {renderChild()}
        </View>
    )

}
